<template>
  <div class="live item">
    <div class="item-h">
      <span class="line"></span>
      <b class="ftz16">Ta的直播</b>
      <a href="javascript:void(0)" class="fr" v-if="list.length > 0" @click.stop.prevent="linkToDashboard()">进入直播间></a>
    </div>
    <div class="con">
      <NoDataTips v-if="list.length === 0"/>
      <ul v-else>
        <li v-for="item in list" :key="item.id">
          <router-link :to="'/liveRoom?roomId=' + item.roomId">
            <span class="time">{{item.createTime | parseTime('{h}:{i}')}}</span>
            <span class="info fr">{{item.topicName}}</span>
          </router-link>
        </li>
      </ul>
    </div>
  </div>
</template>

<script>
import { mapState } from 'vuex'
export default {
  props: ['list', 'authorId', 'roomId'],
  computed: {
    ...mapState({
      userInfo: state => state.me.sysUser || {}
    }),
    userId () {
      return this.$store.state.me.sysUser.userId
    }
  },
  methods: {
    linkToDashboard () {
      if (this.userId === this.authorId) {
        if (this.userInfo.authType === '0') {
          this.$router.push('/dashboardUser/live')
        } else {
          this.$router.push('/myLive')
        }
      } else {
        if (this.roomId) {
          this.$router.push(`/liveRoom?roomId=${this.list[0].roomId}`)
        }
      }
    }
  }
}
</script>

<style scoped lang="scss">
.live .item-h{
  padding: 0 4%;
}
.live .con li{
  padding: 14px 6%;
  border-bottom: 1px solid #e6e6e6;
  overflow: auto;
}
.live .con li:last-child{
  border-bottom: 0;
}
.live .con .time{
  color: #f23e3e;
  display: inline-block;
  vertical-align: top;
}
.live .con .info{
  display: inline-block;
  vertical-align: top;
  width: 80%;
  line-height: 22px;
  margin-top: -2px;
}
</style>
